package com.yu.admin.modules.app.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yu.admin.modules.app.mapper.GoodsCategoryAdminMapper;
import com.yu.admin.modules.app.pojo.GoodsCategoryAdmin;
import com.yu.app.pojo.Goods;
import com.yu.app.pojo.GoodsCategory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class GoodsCategoryAdminService {

    @Resource
    private GoodsCategoryAdminMapper goodsCategoryAdminMapper;

    /**
     * 查询所有
     */
    public List<GoodsCategoryAdmin> getAllGoodsCategoryAdmins() {
        return goodsCategoryAdminMapper.selectList(
                new QueryWrapper<GoodsCategoryAdmin>().orderByAsc("display_order")
        );
    }

    // 增加
    @Transactional
    public int addGoodsCategoryAdmin(GoodsCategoryAdmin goodsCategoryAdmin) {
        return goodsCategoryAdminMapper.insert(goodsCategoryAdmin);
    }

    // 批量删除
    @Transactional
    public int deleteGoodsCategoryAdminBatchIds(List<String> goodsCategoryAdminIdList) {
        return goodsCategoryAdminMapper.deleteBatchIds(goodsCategoryAdminIdList);
    }

    // 修改
    @Transactional
    public int updateGoodsCategoryAdmin(GoodsCategoryAdmin goodsCategoryAdmin) {
        return goodsCategoryAdminMapper.updateById(goodsCategoryAdmin);
    }
}
